/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package quartz;

import java.util.Date;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;

/**
 *
 * @author bighead
 */
public class SchedulerManager {

    public static Scheduler getScheduler() {
        return SchedulerFactoryManager.getScheduler();
    }

    public static Date scheduleJob(
            JobDetail jobDetail, Trigger trigger) throws SchedulerException {
        Scheduler sd = SchedulerFactoryManager.getScheduler();
        return sd.scheduleJob(jobDetail, trigger);
    }

    public static boolean removeJob(String jobName, String triggerName)
            throws SchedulerException {
        return removeJob(jobName, JobBuilder.DEFAULT_JOB_GROUP_NAME, triggerName, TriggerBuilder.DEFAULT_TRIGGER_GROUP_NAME);
    }

    public static boolean removeJob(String jobName, String jobGroupName,
            String triggerName, String triggerGroupName)
            throws SchedulerException {
        Scheduler sd = SchedulerFactoryManager.getScheduler();
        sd.pauseTrigger(triggerName, triggerGroupName);
        sd.unscheduleJob(triggerName, triggerGroupName);
        return sd.deleteJob(jobName, jobGroupName);
    }

}
